<template>
	<view class="wrapper">
		<!-- 个人资料 -->
		<view>
			<view class="top">
				<view class="center">
					<view class="center_top">
						<view class="center_img" >
							<!-- 这里可以放自己的静态头像 -->
							<image src="/static/images/person.png"  @tap="handleImageTap"></image>
							<open-data type="userAvatarUrl" class="user_head"></open-data>
						</view>
						<view class="center_info" >
							<view class="center_name">
								<!-- 这里可以放自己的名称图片 -->
								<view>张三</view>
								<view>23XXXXXXXXX</view>
							</view>	
							
						</view>
					</view>
				</view>
			</view>
		</view>

		<!-- 统计 -->
		<view class="count">
			<view class="cell"> 8 <text style="color: #AAAAAA;">我的消息</text> </view>
			<view class="cell"> 14 <text style="color: #AAAAAA;">我的日程</text> </view>
			<view class="cell"> 18 <text style="color: #AAAAAA;">我的足迹</text> </view>
	
		</view>
		<view class="list-cell m-t">
					<text class="cell-tit">消息推送</text>
					<switch checked color="#2eafff" @change="switchChange" />
				</view>
		<view class="list-cell b-b" @click="navTo('关于OUCer校园助手')" hover-class="cell-hover" :hover-stay-time="50">
					<text class="cell-tit">关于我们</text>
					<text class="cell-more yticon icon-you"></text>
				</view>
				<view class="list-cell">
					<text class="cell-tit">检查更新</text>
					<text class="cell-tip">当前版本 1.0.1</text>
					<text class="cell-more yticon icon-you"></text>
				</view>
				<view class="list-cell log-out-btn" @click="toLogout">
					<text class="cell-tit">退出登录</text>
				</view>
			</view>
	</view>
</template>

<script>
import { mapMutations } from 'vuex';

export default {
  methods: {
    ...mapMutations(['logout']),

    navTo(url) {
      uni.navigateTo({
        url: '/pages/register/register'
      });
    },

    handleImageTap() {
      uni.navigateTo({
        url: '/pages/register/register' // 跳转到 register 页面
      });
    }, // 添加逗号

    // 退出登录
    toLogout() {
      uni.showModal({
        content: '确定要退出登录吗',
        success: (e) => {
          if (e.confirm) {
            this.logout();
            setTimeout(() => {
              uni.navigateTo({
                url: '/pages/register/register'
              });
            }, 200);
          }
        }
      });
    },

    // Switch 改变
    switchChange(e) {
      let statusTip = e.detail.value ? '打开' : '关闭';
      uni.showToast({
        title: `${statusTip}消息推送`,
        icon: 'none'
      });
    }
  }
};
</script>

<style lang="less">
	Page {
		font-size: 14px;
	}

	.top {
		width: 100%;
		height: 130px;
		// background: #23EBB9;
		background: #4398ff;
		padding-top: 15px;
		position: relative;
	}

	.center {
		width: 95%;
		height: 100px;
		background: white;
		display: flex;
		flex-direction: column;
		margin: 0 auto;
		border-radius: 5px;
	}

	.center_top {
		display: flex;
		flex-direction: row;
		width: 80%;
		height: 80px;
		margin: 0 auto;
		margin-top: 20rpx;
		border-bottom: 1px solid #EEEEEE;
	}

	.center_img {
		width: 66px;
		height: 66px;
		border-radius: 50%;
		overflow: hidden;
	}

	.center_img image {
		width: 100%;
		height: 100%;
		border-radius: 50%;
	}

	.center_img .user_head {
		width: 100%;
		height: 100%;
	}

	.center_info {
		display: flex;
		flex-direction: column;
		margin-top: 20rpx;
		margin-left: 30px;
	}

	.center_name {
		font-size: 18px;
	}

	.center_phone {
		color: #BEBEBE;
	}


	.center_rank {
		width: 50%;
		height: 35px;
		display: flex;
		flex-direction: row;
	}

	.rank_text {
		height: 35px;
		line-height: 35px;
		margin-left: 10rpx;
		color: #AAAAAA;
	}

	.center_rank image {
		width: 35px;
		height: 35px;
	}


	.center_score image {
		width: 35px;
		height: 35px;
	}

	.wrapper {
		position: absolute;
		top: 0;
		bottom: 0;
		width: 100%;
		background-color: #F4F4F4;
	}

	.profile {
		height: 375rpx;
		background-color: #ea4451;
		display: flex;
		justify-content: center;
		align-items: center;

		.meta {
			.avatar {
				display: block;
				width: 140rpx;
				height: 140rpx;
				border-radius: 50%;
				border: 2rpx solid #fff;
				overflow: hidden;
			}

			.nickname {
				display: block;
				text-align: center;
				margin-top: 20rpx;
				font-size: 30rpx;
				color: #fff;
			}
		}
	}

.count {
		display: flex;
		width: 100%;
		height: 120rpx;
		text-align: center;
		border-radius: 4rpx;
		background-color: #fff;

		position: relative;
		top: 10rpx;

		.cell {
			margin-top: 10rpx;
			flex: 1;
			padding-top: 20rpx;
			font-size: 30rpx;
			color: #333;
		}

		text {
			display: block;
			font-size: 24rpx;
		}
	}

	.orders {
		margin: 20rpx 20rpx 0 20rpx;
		padding: 40rpx 0;
		background-color: #fff;
		border-radius: 4rpx;

		.title {
			padding-left: 20rpx;
			font-size: 30rpx;
			color: #333;
			padding-bottom: 20rpx;
			border-bottom: 1rpx solid #eee;
			margin-top: -30rpx;
		}

		.sorts {
			padding-top: 30rpx;
			text-align: center;
			display: flex;
		}

		[class*="icon-"] {
			flex: 1;
			font-size: 24rpx;

			&::before {
				display: block;
				font-size: 48rpx;
				margin-bottom: 8rpx;
				color: #ea4451;
			}
		}
	}

	.address {
		line-height: 1;
		background-color: #fff;
		font-size: 30rpx;
		padding: 25rpx 0 25rpx 20rpx;
		margin: 10rpx 20rpx;
		color: #333;
		border-radius: 4rpx;
	}

	.extra {
		margin: 10rpx 20rpx;
		background-color: #fff;
		border-radius: 4rpx;

		.item {
			line-height: 1;
			padding: 25rpx 0 25rpx 20rpx;
			border-bottom: 1rpx solid #eee;
			font-size: 30rpx;
			color: #333;
		}

		button {
			text-align: left;
			background-color: #fff;

			&::after {
				border: none;
				border-radius: 0;
			}
		}
	}

	.icon-arrow {
		position: relative;

		&::before {
			position: absolute;
			top: 50%;
			right: 20rpx;
			transform: translateY(-50%);
		}
	}

	.list-cell{
			display:flex;
			align-items:baseline;
			padding: 20upx ;
			line-height:60upx;
			position:relative;
			background: #fff;
			justify-content: center;
			&.log-out-btn{
				margin-top: 40upx;
				.cell-tit{
					color: black;
					text-align: center;
					margin-right: 0;
				}
			}
			&.cell-hover{
				background:#fafafa;
			}
			&.b-b:after{
				left: 30upx;
			}
			&.m-t{
				margin-top: 40px; 
			}
			.cell-more{
				align-self: baseline;
				font-size:18px;
				color:black;
				margin-left:10px;
			}
			.cell-tit{
				flex: 1;
				font-size: 18px;
				color: black;
				margin-right:10upx;
			}
			.cell-tip{
				font-size: 18px;
				color: black;
			}
			switch{
				transform: translateX(16upx) scale(.84);
			}
		}
</style>



